package com.zaofan.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.zaofan.bean.GoodsOrderDetail;
import com.zaofan.dao.GoodsOrderDetailDao;

public class GoodsOrderDetailService {

	private GoodsOrderDetailDao orderDetailDao = new GoodsOrderDetailDao();

	public void delete(GoodsOrderDetail orderDetail) {
		orderDetailDao.del(orderDetail);
	}

	public void add(GoodsOrderDetail orderDetail) {
		orderDetailDao.add(orderDetail);
	}

	public void update(GoodsOrderDetail orderDetail) {
		orderDetailDao.update(orderDetail);
	}

	public List<GoodsOrderDetail> findAll(Map<String, Object> params) {
		List<GoodsOrderDetail> data = orderDetailDao.findAll(params);
		if (data == null) {
			data = new ArrayList<>();
		}
		return data;
	}

	public Long count(Map<String, Object> params) {
		return orderDetailDao.count(params);
	}

	public GoodsOrderDetail findById(Integer id) {
		Map<String, Object> params = new HashMap<>();
		params.put("id", id);
		return orderDetailDao.findOne(params);
	}

	public List<GoodsOrderDetail> findByOrderId(int orderId) {
		Map<String, Object> params = new HashMap<>();
		params.put("orderId", orderId);
		return orderDetailDao.findAll(params);
	}

}
